package proxy.dynamic.v4;

import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.framework.ProxyFactory;
import proxy.dynamic.v1.CalcServiceImpl;

public class Test {

    public static void main(String[] args) {
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.setTarget(new CalcServiceImpl());
        proxyFactory.addAdvice((MethodInterceptor) invocation -> {
            System.out.println("proxy by methodInterceptor");
            return invocation.proceed();
        });
        CalcServiceImpl calcService = (CalcServiceImpl) proxyFactory.getProxy();
        System.out.println(calcService.add(1, 5));
    }
}
